<%@ page pageEncoding="utf-8"%> 
<%@page import="java.sql.*"%>
<%@page import="java.util.*"%>
 
<%
	request.setAttribute("layout","main.jsp");
	request.setAttribute("page_title","温岭选课系统-课程列表");
	List<Hashtable<String, String>> course_list = (List<Hashtable<String, String>>) session.getAttribute("SelectiveCourseList");
	Iterator<Hashtable<String, String>> course_it = course_list.iterator();
	String coursetype = (String)session.getAttribute("coursetype");
	String grade = (String)session.getAttribute("grade");
	String studentId = (String)session.getAttribute("studentId");
%>

<link href="css/jquery.ui.tabs.css" rel="stylesheet">
<link href="css/jquery.ui.theme.css" rel="stylesheet">
<script src="js/jquery-1.5.2.min.js"></script>
<script src="js/jquery-ui-1.8.11.custom.min.js"></script>
<script src="js/jquery.ui.tabs.js"></script>
<script type="text/javascript" src="js/popup.js"></script>

<script type="text/javascript">
	
	function selectcourse(courseId,coursename){
		   $.ajax({
				url: base_path+"Student/select.do",
				type: "POST",
				data: {"courseId":courseId},
				beforeSend: function(XMLHttpRequest){
					return confirm("确定要选修《"+coursename+"》吗?");
				},
				success: function(data, textStatus){
					if(data!=null && data!=""){
						alert(data);
					}else{ 
						alert("恭喜你，选课成功！");
						window.location.href=base_path+"Student/mySelect.do";
					}
				},
				complete: function(XMLHttpRequest, textStatus){

				},
				error: function(){
					alert("网络异常，请重试！");
				}
			});
	   }
</script>

<div style="width:100%; margin:1px;text-align:center;margin-top:10px;margin-bottom:50px;">
 	<p style="border:0;font-size:14px;padding-bottom:0;">
  		<b>2012年第一学期开设课程</b>
	</p>
	<form action="Search/searchCourse.do?src=admin" method="post">
  		<table  style="border:0px solid gray;align:middle;width:50%;margin-left:25%; margin-bottom:20px">
  			<tr>
  				<td>课程类型</td>
  				<td>
  					<select style="width:160px;" name="course_type">
  					<% %>
 					<% if(coursetype!=null && coursetype.trim().equalsIgnoreCase("全部")){%>
 						<option value="全部" selected>全部</option>
 					<% }else {%>
 						<option value="全部">全部</option>
 					<% }if(coursetype!=null && coursetype.trim().equalsIgnoreCase("知识拓展")){%>
 						<option value="知识拓展" selected>知识拓展</option>
 					<% }else {%>
 						<option value="知识拓展">知识拓展</option>
 					<% }if(coursetype!=null && coursetype.trim().equalsIgnoreCase("大学初级课程")){%>
 						<option value="大学初级课程" selected>大学初级课程</option>
 					<% }else {%>
 						<option value="大学初级课程">大学初级课程</option>
 					<%} if(coursetype!=null && coursetype.trim().equalsIgnoreCase("学科应用")){%>
 						<option value="学科应用" selected>学科应用</option>
 					<%} else {%>
 						<option value="学科应用">学科应用</option>
 					<%} if(coursetype!=null && coursetype.trim().equalsIgnoreCase("兴趣特长培养")){%>
 						<option value="兴趣特长培养" selected>兴趣特长培养</option>
 					<%} else {%>
 						<option value="兴趣特长培养">兴趣特长培养</option>
 					<%} if(coursetype!=null && coursetype.trim().equalsIgnoreCase("社会实践活动")){%>
 						<option value="社会实践活动" selected>社会实践活动</option>
 					<%} else {%>
 						<option value="社会实践活动">社会实践活动</option>
 					<%} if(coursetype!=null && coursetype.trim().equalsIgnoreCase("职业技术培训")){%>
 						<option value="职业技术培训" selected>职业技术培训</option>
 					<%} else {%>
 						<option value="职业技术培训">职业技术培训</option>
 						<%} %>
 					</select>
  				</td>
  				<td>&nbsp;&nbsp;年级</td>
  				<td>
  					<select style="width:160px;" name="grade">
 					<% if(grade!=null && grade.trim().equalsIgnoreCase("全部")){%>
 						<option value="全部" selected>全部</option>
 					<% }else {%>
 						<option value="全部">全部</option>
 					<% }if(grade!=null && grade.trim().equalsIgnoreCase("高一年级")){%>
 						<option value="高一年级" selected>高一年级</option>
 					<% }else {%>
 						<option value="高一年级">高一年级</option>
 					<% }if(grade!=null && grade.trim().equalsIgnoreCase("高二年级")){%>
 						<option value="高二年级" selected>高二年级</option>
 					<% }else {%>
 						<option value="高二年级">高二年级</option>
 					<%} if(grade!=null && grade.trim().equalsIgnoreCase("高三年级")){%>
 						<option value="高三年级" selected>高三年级</option>
 					<%} else {%>
 						<option value="高三年级">高三年级</option>
 						<%} %>
 					</select>
  				</td>
  				<td><input type="submit" value="查询"/></td>
  			</tr>
  		</table>
  </form>
  <table   style="border:1px solid gray;margin-left:1%;width:98%;">
    <tbody>
              <tr height="32" bgcolor="#f0f0f0">
                    <td align="center" width="7%">课程编号</td>
		            <td align="center" width="12%">学期</td>
                    <td align="center" width="12%">课程类型</td>
                    <td align="center" width="10%">课程名称</td>
                    <td align="center" width="7%">教师</td>
                    <td align="center" width="13%">上课时间|地点</td>
                    <td align="center" width="10%">可选年级</td>
                    <td align="center" width="6%">人数限额<br>
                      (最多/最少)</td>
                    <td align="center" width="6%">已选人数</td>
                    <td align="center" width="6%">学分</td>
                    <td align="center" width="15%">操作</td>
              </tr>
              <%
              		course_it = course_list.iterator();
		        	while(course_it.hasNext())
					{
						Hashtable<String, String> cousrelist_hash  = course_it.next();
			 %>
			  	<tr height="25" bgcolor="#ffffff">
		            <td align="center"><%=cousrelist_hash.get("classno") %></td>
			  		<td align="center"><%=cousrelist_hash.get("year") %><%=cousrelist_hash.get("openterm") %></td>
		            <td align="center"><%=cousrelist_hash.get("type") %></td>
		            <td align="center"><%=cousrelist_hash.get("name") %> </td>
		            <td align="center"><%=cousrelist_hash.get("teachers") %> </td>
		            <td align="center"><%=cousrelist_hash.get("teach_time") %> | <%=cousrelist_hash.get("teach_location") %> </td>
		            <td align="center"><%=cousrelist_hash.get("grade") %> </td>
		            <td align="center"><%=cousrelist_hash.get("students_low") %>/<%=cousrelist_hash.get("students_high") %> </td>
		            <td align="center"><%=cousrelist_hash.get("num_of_students") %> </td>
		            <td align="center"><%=cousrelist_hash.get("credit") %> </td>
		            <td align="center">
		                 <!-- <a href="javascript:selectcourse(<%//=cousrelist_hash.get("Id") %>,<%//=cousrelist_hash.get("name") %>)"  class="approve">选课</a> -->
		            	<a href="Admin/select.do?courseId=<%=cousrelist_hash.get("Id")%>&studentId=<%=studentId%>&src=studentview"  class="approve">选课</a>
		            </td>
		         </tr>
			  <%} %>
      </tbody>
    </table>
</div>
